<?php

/** Frame
 * Frameset
 * Noframes
 * */
include_once 'Answer_Patterns.php';
include_once 'Mount_DOM_tree.php';

class Refactoring_Old_Tags_Div extends Answer_Patterns {

   public function start($domDocument) {
      $result = "";
      $mount_tree = new Mount_DOM_tree();

      $search = $domDocument->getElementsByTagName('frame');
      foreach ($search as $f) {
         $answer = '&LT;div&GT; Conteudo do arquivo ' . $f->getAttribute('src') . ' &LT;/div&GT;';
         $result .= parent::elementAnswerPatterns("&LT;$f->nodeName&GT;", $f->getLineNo(), $answer, "Elemento não é mais suportado ", "substituir por <em>&LT;div&GT;</em>");
         $result .= parent::tableAnswer($mount_tree->structHTML($f, 1, 0), $answer);
      }

      $search = $domDocument->getElementsByTagName('frameset');
      foreach ($search as $f) {
         $answer = '&LT;div style="" &GT;...&LT;/div&GT;';
         $result .= parent::elementAnswerPatterns("&LT;$f->nodeName&GT;", $f->getLineNo(), $answer, "Elemento não é mais suportado ", "substituir por <em>&LT;div&GT;</em>");
         $result .= parent::tableAnswer($mount_tree->structHTML($f, 1, 0), $answer);
      }

      $search = $domDocument->getElementsByTagName('noframes');
      foreach ($search as $f) {
         $answer = '';
         $result .= parent::elementAnswerPatterns("&LT;$f->nodeName&GT;", $f->getLineNo(), $answer, "Elemento não é mais suportado", " remover o elemento");
         $result .= parent::tableAnswer($mount_tree->structHTML($f, 1, 0), $answer);
      }

      if (!empty($result)) {
         $result = parent::titleAnswerPatterns("Substituir elementos que foram descontinuados por tags &LT;div&GT; ou apenas remover o elemento") . $result;
      }
      return $result;
   }

}
